<template>
	<el-drawer title="车辆调度详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
					<el-form-item label="用车标题" prop="title">{{form.title}}</el-form-item>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="车辆类型" prop="type">{{form.typeName}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="用车人" prop="usedUser">{{form.usedUserName}}</el-form-item>
						</el-col>
					</el-row>
					<el-form-item label="用车事由" prop="cause">{{form.cause}}</el-form-item>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="出发地点" prop="sourceAddress">{{form.sourceAddress}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="目的地" prop="destination">{{form.destination}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="大约里程" prop="mileage">{{form.mileage}}/公里</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="是否需要油卡" prop="card">{{form.card=='0'?'不需要':'需要'}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="开始时间" prop="beginTime">{{form.beginTime}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="结束时间" prop="endTime">{{form.endTime}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="是否需要司机" prop="driver">{{form.driver=='0'?'不需要':'需要'}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="随车人员" prop="passenger">{{form.passenger}}/人</el-form-item>
						</el-col>
					</el-row>
					<el-form-item label="备注说明" prop="remark">{{form.remark}}</el-form-item>
				</el-form>
				<el-divider>调拨意见</el-divider>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="指定司机" prop="targetDriver">{{resForm.driverName}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="发放油卡" prop="oilCard">{{resForm.cardNo}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="指派车辆" prop="vehicleId">{{resForm.vehicleNumber}}
							</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="审批意见" prop="status">{{resForm.status==0?'审批中':(resForm.status=='1'?'同意':'不同意')}}
							</el-form-item>
						</el-col>
					</el-row>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	emits: ['success', 'closed'],
	components: {
		AttachMenu,
	},
	data() {
		return {
			loading: false,
			resForm:{
				driverName:'',
				optUserName:'',
				cardNo:'',
				vehicleNumber:'',
				status:'',
			},
			form: {
				applyId: '',
				type: '',
				typeName:'',
				title: '',
				usedUser: '',
				usedUserName:'',
				cause: '',
				beginTime: '',
				endTime: '',
				sourceAddress: '',
				destination: '',
				mileage: 0,
				card: '0',
				driver: '0',
				optUser: '',
				passenger: '',
				remark: ''
			},
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},
		async getVehicleApprovalResult(applyId)
		{
			let res = await this.$API.office.vehicle.getVehicleApprovalResult.get({applyId:applyId});
			if (res.code == 200) {
				this.resForm = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		//表单注入数据
		setData(data) {
			this.form.applyId = data.applyId
			this.form.typeName = data.typeName
			this.form.type = data.type
			this.form.title = data.title
			this.form.usedUser = data.usedUser
			this.form.usedUserName = data.usedUserName
			this.form.cause = data.cause
			this.form.beginTime = data.beginTime
			this.form.endTime = data.endTime
			this.form.sourceAddress = data.sourceAddress
			this.form.destination = data.destination
			this.form.mileage = data.mileage
			this.form.card = data.card
			this.form.driver = data.driver
			this.form.optUser = data.optUser
			this.form.passenger = data.passenger
			this.form.remark = data.remark
			this.getVehicleApprovalResult(data.applyId);
		},
	}
}
</script>

<style>
</style>
